<template>
  <div>
    <div class="title txt-center">问题中心</div>
    <!-- <snap-shot v-for="item in articleList"
            v-bind="item" 
            :key='item.id'
            :content='item.con'
            :path='"/notice/detail/"+item.id'>
            <div class="statistic">
                <span>{{$t("view")||"阅读"}}：<em v-text="item.num"></em></span>
                <span>{{$t("updateTime")||"更新时间"}}：<em v-text="item.writedate"></em></span>
            </div>
        </snap-shot> -->
        <div class="sysnews">
          <div v-for="item in centres" :key="item" @click="getquesttitle(item)">
            <img :src="item.logo" alt="">
            <span>{{item.name}}</span>
          </div>
        </div>
        <div class="aidOption">
          <div>
            <h3>问题列表</h3>
            <ul v-if="selects&&selects[0]">
              <li v-for="item in selects" :key="item" @click="getquestcontent(item)">
                <p>{{item.title}}</p>
              </li>
            </ul>
            <div
              class="no-data"
              v-else
              v-text="$t('label108')"
            ></div> 
          </div>
          
          <div>
            <ul v-for="item in details" :key="item">
              <li>{{item.title}}</li>
              <li>
                <span>阅读量: {{item.readnum}}</span>
                <span>点赞人数: {{item.rights}}</span>
                <span>反对人数: {{item.wrong}}</span>
                <span>发布时间: {{item.wdate}}</span>
              </li>
              <li>
                <div v-html="item.reply"></div>
              </li>
              <el-radio-group class="evaluate" v-model="radio" :disabled="disabled"  fill='#474D6F' @change="updatequestright(item)">
                <el-radio-button  label="好评"></el-radio-button>
                <el-radio-button  label="差评"></el-radio-button>
              </el-radio-group>
            </ul>
          </div>
        </div>
    </div>
  </div>
</template>
<script>
import newsModel from "@/model/newsModel.js";
let { newsList } = newsModel;
import snapShot from "@/components/SnapShot.vue";
export default {
  components: {
    snapShot
  },
  data() {
    return {
      disabled: false,
      radio: "",
      articleList: newsList,
      centres: [],
      selects: [],
      details: [],

      autoid:"",
    };
  },
  mounted() {
    // !newsList && this.getNewsList();
    this.getquestmenu();
  },
  methods: {
    getquestmenu() {
      this.request(this.api.getquestmenu).then(res => {
        if (res.code == "0") {
          this.centres = res.data;
          let idOne = res.data[0].pid;
          this.request(this.api.getquesttitle,{id:idOne}).then(res => {
            if(res.code == '0'&& res.data.length>0) {
              this.selects = res.data;
              let idTwo = res.data[0].autoid;
              console.log(idTwo);
              return this.request(this.api.getquestcontent,{id:idTwo}).then(res => {
                if(res.code == '0') {
                  this.details = res.data;
                }
              })
            }
          });
        }
      });
    },
    getquesttitle(item) {
      let autoid = item.pid;
      this.request(this.api.getquesttitle, { id: autoid }).then(res => {
        if (res.code == "0") {
          this.selects = res.data;
          let idTwo = res.data[0].autoid;
              console.log(idTwo);
              return this.request(this.api.getquestcontent,{id:idTwo}).then(res => {
                if(res.code == '0') {
                  this.details = res.data;
                }
          })
        }
      });
    },
    getquestcontent(id) {
      this.request(this.api.getquestcontent, { id: id }).then(res => {
        if (res.code == "0") {
          res.data.forEach(item => {
            item.disabled = false;
          });
          this.radio="";
          this.details = res.data;
        }
      });
    },
    updatequestright(item) {
      let autoids = item.autoid;
      let types;
      if (this.radio == "好评") {
        types = "1";
      } else {
        types = "0";
      }
      this.request(this.api.updatequestright,{id:autoids,type:types}).then(res => {
        if(res.code == '0') {
          this.successMsg(res.msg || "操作成功");
          // this.getDataFaild(res.msg);
          this.disabled = true;
          this.getquestcontent();
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.statistic {
  color: #999;
  font-size: 12px;
  span {
    margin-right: 25px;
  }
}
.title {
  margin: 2% 10%;
  font-size: 24px;
  color: #fff;
  // padding-bottom: 15px;
  // border-bottom: 1px solid rgb(122, 122, 122);
}
.sysnews {
  margin: 2% 10%;
  margin-bottom: 25px;
  border-bottom: 1px solid $elcon_border;
  >div {
    width: 250px;
    height: 60px;
    margin: 20px;
    background-color: #fff;
    text-align: center;
    border-radius: 5px;
    display: inline-block;
    position: relative;
    img {
      width: 30px;
      position: absolute;
      top: 50%;
      left: 35%;
      transform: translate(-50%, -50%);
    }
    span {
      color: #000;
      line-height: 60px;
    }
  }
  > div:hover {
    background-color: #474d6f;
    span {
      color: #fff;
    }
  }
  // li{
  //   border-bottom: 1px solid #eeeeee;padding:2px 0;
  //   h3{height: 30px;font-size: 16px;line-height: 30px;font-weight: 500;}
  //   span{font-weight: 400;margin-right: 5px;}
  //   p{line-height: 20px;}
  //   .info{color: $bg-dark; }
  // }
  // li:hover h3{color: $bg-dark; }
  // li:hover{background: #eeeeee;}
  // .c_hui{color: #999999;}
}
.aidOption {
  padding: 2% 10%;
  min-height: 500px;
  background-color: #fff;
  > div:nth-child(1) {
    width: 20%;
    background: #ffffff;
    display: inline-block;
    border-radius: 5px;
    float: left;
    h3 {
      padding: 3%;
      font-size: 18px;
      font-weight: bold;
    }
    p {
      padding: 3%;
      margin: 2% 0;
      line-height: 18px;
      font-size: 15px;
      letter-spacing: 1px;
      border-bottom: 1px solid #ccc;
    }
    p:hover {
      background-color: #474d6f;
      border-radius: 3px;
      color: #fff;
    }
  }
  > div:nth-child(2) {
    width: 75%;
    display: inline-block;
    margin-left: 25px;
    ul {
      li:nth-child(1) {
        font-size: 28px;
        font-weight: bold;
        text-align: center;
      }
      li:nth-child(2) {
        color: rgb(151, 151, 151);
        margin: 20px 0 10px;
        span {
          margin-right: 5px;
          font-size: 14px;
        }
      }
      li:nth-child(3) {
        font-size: 16px;
        letter-spacing: 1px;
        line-height: 25px;
      }
    }
  }
}
.evaluate {
  // float: right;
  border-top: 1px solid #ccc;
  width: 100%;
  margin-top: 100px;
  padding-top: 20px;
  text-align: right;
  .el-radio-button {
  }
}
.no-data{text-align: center;}
</style>

